package com.su.song.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.su.song.myapplication.Util.DataUtil;

public class MainActivity_onclick extends AppCompatActivity implements View.OnClickListener {

    private TextView tv_result;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_onclick);
        tv_result = findViewById(R.id.tv_show);
        Button btn_onclick = findViewById(R.id.tv_onclick);
        btn_onclick.setOnClickListener(this);

    }
    @Override
    public void onClick(View v) {
      if(v.getId() == R.id.tv_onclick){
              String desc = String.format("%s 您点击了按钮: %s", DataUtil.getNowTime(),((Button) v).getText());
              tv_result.setText(desc);
      }
    }
//还有匿名内部类的方式点击触发，还有新建类进行触发



}